//
//  IcAppViewController.m
//  IceClear
//
//  Created by P & C on 2/23/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "IcAppViewController.h"


@implementation IcAppViewController

@synthesize mainTabBar;

// The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
/*
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization.
    }
    return self;
}
*/

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
 
	IcHomeViewController* homeController = [[IcHomeViewController alloc] initWithNibName:@"IcHomeViewController" bundle:nil];
	IcAntiIcingTipsViewController* vcATips = [[IcAntiIcingTipsViewController alloc] 
											  initWithNibName:@"IcAntiIcingTipsViewController" bundle:nil];
	IcRecommenationsListViewController* vcRecsList = [[IcRecommenationsListViewController alloc] 
													initWithNibName:@"IcRecommenationsListViewController" bundle:nil];
	
	vcRecsList.title = @"My Recommendations";
	
	UINavigationController* recsTabNavController = [[UINavigationController alloc] initWithRootViewController:vcRecsList];
	
	homeController.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"Home" image:[UIImage imageNamed:@"house_22.png"] tag:0];
	vcATips.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"Anti-Icing Tips" image:[UIImage imageNamed:@"ice_24.png"] tag:0];
	recsTabNavController.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"Recommendations" image:[UIImage imageNamed:@"article_24.png"] tag:0];
	
	NSArray* tabBarControllers = [NSArray arrayWithObjects:homeController, vcATips, recsTabNavController, nil];
	
	mainTabBar.viewControllers = tabBarControllers;
	
	[self.view addSubview:mainTabBar.view];
}

/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations.
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc. that aren't in use.
}

- (void)viewDidUnload {
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


#pragma mark tabBarController delegation

- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController {
	return YES;
}

- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController {
	
}


- (void)dealloc {
	[super dealloc];
}


@end
